import * as types from '../mutation-types.js'
import apiurl from '@/api/apiurl'
// import Api from '@/api/index'

//全局状态
const state = {
  mapParams: ''
}

//getters
const getters = {
  mapParams: state => {
    return state.mapParams
  },
}

const mutations = {
  [types.SET_MAPPARAMS] (state, mapParams) {
    state.mapParams = mapParams
  }
}

const actions = {

  /**
   * 获取告警列表
   * @param params{ status: '案件编号', facilityNum: 'IMEI', createTime: '創建時間' }
   * @returns { status: 1, result: [{}], message: '获取告警列表成功' }
   */
  async fetchAlarmList(_, params = {}) {
    // console.log(params,'获取告警列表')
    // console.log(apiurl.alarmList)
    let res = await Api.request(apiurl.alarmList, {
      ...params
    })
    // console.log(res)
    return res
  },
  
  /**
   * 修改告警狀態
   * @param params{ id: '報警id', status: '0-未读，1-已读' }
   * @returns { status: 1, result: [{}], message: '修改成功' }
   */
  async fetchAlarmStatusUpdate(_, params = {}) {
    console.log(params,'修改告警狀態')
    console.log(apiurl.alarmStatusUpdate)
    let res = await Api.request(apiurl.alarmStatusUpdate, {
      ...params
    })
    console.log(res)
    return res
  },

}

export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions
}
